package cn.xiaoyu.su.controller;


import cn.xiaoyu.su.controller.request.LoginRequest;
import cn.xiaoyu.su.controller.request.UserRegisterRequest;
import cn.xiaoyu.su.service.AccountService;
import cn.xiaoyu.su.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ⼆当家⼩D
 * @since 2022-10-27
 */
@RestController
@RequestMapping("/api/account/v1")
public class AccountController {

    @Autowired
    private AccountService accountService;

    /**
     * 新用户注册
     * @param userRegisterRequest
     * @return
     */
    @PostMapping("register")
    public JsonData register(@RequestBody UserRegisterRequest userRegisterRequest) {

        return accountService.register(userRegisterRequest);
    }

    @PostMapping("login")
    public JsonData login(@RequestBody LoginRequest loginRequest) {

        return accountService.login(loginRequest);
    }
}

